package com.randi.framework.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.randi.common.core.domain.entity.SysMenu;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author ziye
 */
@Data
@ApiModel(value = "RouterMeta", description = "菜单元信息对象")
public class RouterMeta {

    @ApiModelProperty(value = "标题名称")
    private String title;

    @ApiModelProperty(value = "图标")
    private String icon;

    @ApiModelProperty(value = "菜单权限")
    private String auth;

    @ApiModelProperty(value = "内链地址", notes = "http(s)://开头")
    private String link;

    @ApiModelProperty(value = "显示顺序")
    private Integer order;

    @ApiModelProperty(value = "自动关闭标签页", notes = "1：离开当前页关闭标签页")
    private Integer tabClose;

    @ApiModelProperty(value = "显示状态", notes = "0：显示 1：隐藏")
    private Integer hidden;

    @ApiModelProperty(value = "菜单状态", notes = "0：正常 1：禁用")
    private Integer status;

    @TableField(value = "`link_type`")
    @ApiModelProperty(value = "链接类型", notes = "0：内部 1：外部")
    private Integer linkType;

    @TableField(value = "`cache_enable`")
    @ApiModelProperty(value = "是否缓存（0缓存 1不缓存）")
    private Integer cacheEnable;

    public RouterMeta() {}

    public RouterMeta(SysMenu sysMenu){
        this.title = sysMenu.getMenuName();
        this.icon = sysMenu.getMenuIcon();
        this.auth = sysMenu.getMenuCode();
        this.order = sysMenu.getOrderNum();
        this.status = sysMenu.getStatus();
        this.tabClose = sysMenu.getTabClose();
        this.cacheEnable = sysMenu.getCacheEnable();
        this.linkType = sysMenu.getLinkType();
        this.hidden = sysMenu.getVisible();
        this.link = sysMenu.getMenuPath();
    }
}
